package com.bxait.toymail.search.controller;

import com.bxait.toymail.search.service.MallSearchService;
import com.bxait.toymail.search.vo.SearchParam;
import com.bxait.toymail.search.vo.SearchResult;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/*
@description:
@ClassName SearchController
@author Chen
@create 2023-04-15 18:59
@Version 1.0
*/
@Controller
public class SearchController {

    @Resource
    @Qualifier("mallSearchService")
    MallSearchService searchService;

    /*
     * @param 
     * @==============History===============<br/>
     * @Description //   处理页面请求,将请求携带的参数进行解析在es中进行检索返回
     * @Date 2023/4/15 2023/4/15 
     * @Author < a href="2277411582@qq.com">chen</ a>
     * @return []
     */
    @GetMapping("/list.html")
    public String listPage(SearchParam param, Model model, HttpServletRequest request){
        // 1.获取上一次请求地址中携带的查询条件
        param.set_queryString(request.getQueryString());
        // 2.检索出查询出的数据
        SearchResult result = searchService.search(param);
        model.addAttribute("result",result);
        // 3.跳转页面
        return "list";
    }
}

